package com.example.mavendemo.controller;


import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping ("/b")
@Controller
public class IndexController {

    @RequestMapping("/getIndex")
    public String getIndex() {
        return "/index.html";
    }

    @ResponseBody
    @RequestMapping("/returnHtml")
    public String returnHtml() {
        return "<h1>这是一个html片段</h1>";
    }

    @ResponseBody
    @RequestMapping("/retObject")
    public Person retObject() {
        Person person = new Person();
        person.setAge(13);
        person.setId("1");
        person.setName("zhangsan");
        return person;
    }

    @ResponseBody
    @RequestMapping("/setStatus")
    public String setStatus(HttpServletResponse response) {
        response.setStatus(402);
        return "设置状态码成功";
    }

    @ResponseBody
    @RequestMapping(value = "/setHeader",produces = "application/json;charset=utf8")
    public String setHeader(HttpServletResponse response) {
        return "{1,OK}";
    }
}



